-- floor
-- created by panyl
-- 战斗统计规则：层数

local handle = function(para)
    -- 如果不是在地牢内就忽略
    if not DungeonM.isInDungeon() then
        return;
    end
    
    -- 增加进度
    local id = CombatStatM.queryByRule("floor", "id");
    
    -- 当前进度
    local currProgress = CombatStatM.getProgress(id);
    local floor = DungeonM.currentLayer();
    if currProgress >= floor then
        return;
    end
    
    -- 设置进度
    CombatStatM.setProgress(id, floor);
end

EventMgr.register("floor", event.NEXT_FLOOR, handle);
EventMgr.register("floor", event.START_DUNGEON, handle);

return {
    progress = function()
        local id = CombatStatM.queryByRule("floor", "id");
        local floor = CombatStatM.getProgress(id);
        if floor == 0 then
            floor = 1;
        end
        
        return floor;
    end,
};
